package com.xy.weatherDate;

/**
 * @author 谢阳
 * @version 1.8.0_131
 * @date 2022/6/19 10:11
 * @description
 */
public class AndroidWeatherApp implements Observer,DisplayElement{
    // 天气信息
    private float temperature; // 温度
    private float humidity; // 湿度
    private float pressure; // 气压
    // 主题
    private WeatherData weatherData;

    public AndroidWeatherApp(WeatherData weatherData) {
        this.weatherData = weatherData;
        weatherData.registerObserver(this);
        update();
    }

    @Override
    public void display() {
        System.out.println("---android weather app----");
        System.out.println("温度:" + temperature);
        System.out.println("湿度:" + humidity);
        System.out.println("气压:" + pressure);
        System.out.println("--------------------------");
    }


    @Override
    public void update() {
        temperature = weatherData.getTemperature();
        humidity = weatherData.getHumidity();
        pressure = weatherData.getPressure();
        // 显示信息
        display();
    }
}
